package beans;

import DAO.dao;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import objects.User;
import DAO.dao;
import java.util.List;

@Named
@SessionScoped
public class UserBean implements Serializable {
	private User u;
	
	/*public boolean validPassword(){
		return u.ValidPassword();
	}*/
        
	
    public User getUser(){
        return u;
    }  
    
    public String createUser(){
        dao.addUser(u);
        return "Welcome";
    }
    
    public String newUser(){
        u = new User();
        return "opretBruger";
    }
    
    public List<User> getUsers(){
        return dao.getUsers();
    }
    
    public void brugerNavnValidation(FacesContext fc, UIComponent c, Object value) {
	   /*if (((String) value).contains("_"))
	      throw new ValidatorException(
	         new FacesMessage("Name cannot contain underscores"));*/
   }
    
    public void emailValidation(FacesContext fc, UIComponent c, Object value) {
	   /*if (((String) value).contains("_"))
	      throw new ValidatorException(
	         new FacesMessage("Name cannot contain underscores"));*/
   }
}
